package org.hzero.order.infra.repository.impl;

import java.util.List;

import org.hzero.boot.platform.lov.annotation.ProcessLovValue;
import org.hzero.mybatis.base.impl.BaseRepositoryImpl;
import org.hzero.order.domain.entity.dto.OrderDTO;
import org.hzero.order.domain.repository.OrderRepository;
import org.hzero.order.infra.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import io.choerodon.core.domain.Page;
import io.choerodon.mybatis.pagehelper.PageHelper;
import io.choerodon.mybatis.pagehelper.domain.PageRequest;

/**
 * @author xiuiqng.Yang-Estelle-양수청
 * @date 2019/8/6 16:08
 */
@Repository
public class OrderRepositoryImpl extends BaseRepositoryImpl<OrderDTO> implements OrderRepository {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public Page<OrderDTO> pageOrder(OrderDTO attr, PageRequest pageRequest) {
        return PageHelper.doPage(pageRequest, ()-> orderMapper.select(attr));
    }

    @Override
    public Page<OrderDTO> pageOrderDetail(String orderNumber, PageRequest pageRequest) {
        return PageHelper.doPage(pageRequest, ()->orderMapper.selectByOrderNumber(orderNumber));
    }

    @ProcessLovValue
    @Override
    public List<OrderDTO> export(PageRequest pageRequest) {
        return PageHelper.doPage(pageRequest, ()->orderMapper.selectExportAttrs());
    }
}
